//获取url后的参数值
function getUrlParam(key) {
    var href = window.location.href;
    var url = href.split("?");
    if(url.length <= 1){
        return "";
    }
    var params = url[1].split("&");

    for(var i=0; i<params.length; i++){
        var param = params[i].split("=");
        if(key == param[0]){
            return param[1];
        }
    }
}
function layuiUpload(elem, layupload, layer) {
    var uploadInst = layupload.render({
        elem: elem
        , url: '/api/files/uploadImg' //改成您自己的上传接口
        , acceptMime: 'image/*'
        , accept: 'images'
        , before: function (obj) {
            obj.preview(function (index, file, result) {
                $(elem + 'Img').attr('src', result);
            });
        }
        , done: function (res) {
            //如果上传失败
            if (res.code != 1) {
                showmsg("上传失败", 0);
            } else {
                $(elem).val(res.data.url);
            }
        }
        , error: function () {
            var shopLogoText = $(elem + 'Text');
            shopLogoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs upload-reload">重试</a>');
            shopLogoText.find('.upload-reload').on('click', function () {
                uploadInst.upload();
            });
        }
    });
    return uploadInst;
}